'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
    const { router, controller, jwt } = app;

    router.get('/', controller.home.index);
    //用户注册
    router.post('/register', controller.user.register);
    //用户登录
    router.post('/login', controller.user.login);
    //发布文章
    router.post('/write', jwt, controller.user.write);
    //获取用户基本信息
    router.get('/getUserInfo', controller.user.getUserInfo);
    //获取分类列表
    router.get('/getCategoryList', controller.user.getCategoryList);
    //获取用户发表文章
    router.get('/getArticlesByPage', controller.user.getArticlesByPage);
    //根据文章ID获取内容
    router.get('/getArticlesById', controller.user.getArticlesById);
    //获取qntoken
    router.post('/qntoken', jwt, controller.user.getToken);
    //关注用户
    router.get('/follow', jwt, controller.user.followUser);
    //取消关注用户
    router.get('/unfollow', jwt, controller.user.unfollowUser);
    //获取用户关注的用户信息
    router.get('/getfollowing', controller.user.getFollowings);
    //获取用户粉丝信息
    router.get('/getfollower', controller.user.getFollowers);
    //获取用户关注数和粉丝数
    router.get('/getfollowinfo', controller.user.getFollowInfo);
    //点赞文章
    router.get('/like', jwt, controller.user.likeArticle);
    //取消点赞文章
    router.get('/unlike', jwt, controller.user.unlikeArticle);
    //根据分类id分页获取内容
    router.get('/getLists', controller.user.getListByCategory);
    //根据用户id获取被点赞数和被阅读数
    router.get('/get_multi_user', controller.user.getLikedAndViewdCount);
    //获取收藏夹列表
    router.get('/getFavoriteList', jwt, controller.user.getFavoriteList);

    // 新建文件夹
    router.post('/addFolder', jwt, controller.user.addFolder);
    //收藏文章
    router.get('/collection', jwt, controller.user.collection);
    //取消收藏
    router.get('/cancelCollection', jwt, controller.user.cancelCollection);
    //删除收藏夹
    router.get('/deleteFavorites', jwt, controller.user.deleteFavorites);
    //获取收藏夹列表详细信息
    router.get('/getFavoriteListInfo', controller.user.getFavoriteListInfo);
    // 根据收藏夹id获取内部文章信息
    router.get('/getArticlesByFavoriteId', controller.user.getArticlesByFavoriteId);

    //更新用户头像
    router.post('/updateAvatar', jwt, controller.user.updateAvatar);
    //更新用户其他信息
    router.post('/updateUserInfo', jwt, controller.user.updateUserInfo);


    //获取文章评论信息
    router.get('/getAllComments', controller.user.getAllComments);
    //回复
    router.post('/sendReply', jwt, controller.user.sendReply);
    // 评论
    router.post('/sendComment', jwt, controller.user.sendComment);
    // 根据关键字查询文章
    router.get('/getArticlesByKeyword', controller.user.getArticlesByKeyword);

    //获取热门作者
    router.get('/getHotAuthor', controller.user.getHotAuthor);
};